package com.njitt.bysj.controller;

import com.njitt.bysj.base.BaseController;
import com.njitt.bysj.base.ResultInfo;
import com.njitt.bysj.srevice.LoginService;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @author :wyanjia
 * @parm : 首页controller
 * @date : 2022/3/17 21:39
 * @return :
 */
@Controller
public class IndexController extends BaseController {
    @Resource
    private LoginService service;

    @RequestMapping("/main")
    public String main() {
        return "main";
    }

    @RequestMapping("welcome")
    public String welcome() {
        return "welcome";
    }

    @RequestMapping("/index")
    public String index() {
        return "login";
    }

    @RequestMapping("/user/login")
    @ResponseBody
    public ResultInfo login(String username, String password, Boolean rememberMe) {
        rememberMe= true;
        UsernamePasswordToken token = new UsernamePasswordToken(username, password);
        ResultInfo resultInfo = service.queryUserByAccount(token, rememberMe);
        System.out.println(resultInfo);
        return resultInfo;
    }

    @RequestMapping("uIndex")
    public String toIndex() {
        return "uIndex";
    }

    @RequestMapping("test")
    public String test() {
        return "test";
    }
}
